package com.cloud.rou.im.router.handler;

import com.cloud.rou.im.msg.LoginMsg;
import com.cloud.rou.im.protocol.transfer.DataPacketFactory;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.AttributeKey;
import lombok.extern.slf4j.Slf4j;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
@Slf4j
public class ClientLoginHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
         // 发送登录成功消息
        Long id = 999L;
        LoginMsg msg = LoginMsg.builder().senderId(id).password("qqq").recipientId(2L).build();
        log.info("[UserId:{}]：请求登录",id);
        ctx.writeAndFlush(DataPacketFactory.getPacket(msg));
        //移除当前的handler
        ctx.pipeline().remove(this);
    }
}
